<?php

namespace App\Providers;


use App\Services\EmailService;
use App\Services\MailService;
use Illuminate\Support\ServiceProvider;

class EmailServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->registerEmailService();
    }

    protected function registerEmailService(){


        $this->app->bind('emailService',function () {//单例模式，直接使用singleton方法绑定关系
            return new EmailService(new MailService());
        });
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}
